package com.project_doctor.mapper;

import com.project_doctor.pojo.Doctor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project_doctor.pojo.Dto.DoctorRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
/**
* @author 龙龙与贝儿
* @description 针对表【t_doctor】的数据库操作Mapper
* @createDate 2025-06-03 11:07:18
* @Entity com.project_doctor.pojo.Doctor
*/
public interface DoctorMapper extends BaseMapper<Doctor> {


    List<Doctor> getAllDoctorsWithRoleAndTeam(DoctorRequest doctorRequest);

    @Select("<script>" +
            "SELECT d.*, t.id as team_id, t.team_name AS team_name, r.id as role_id, r.role_name " +
            "FROM t_team t " +
            "INNER JOIN t_doctor d ON d.team_id = t.id " +
            "INNER JOIN t_role r ON d.role_id = r.id " +
            "WHERE d.id IN " +
            "<foreach item='id' collection='ids' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    @Results({
            @Result(property = "id", column = "id"), // 主键映射（如果 Doctor 有 @Id 可省略）
            @Result(property = "team.id", column = "team_id"),
            @Result(property = "team.teamName", column = "team_name"),
            @Result(property = "role.id", column = "role_id"),
            @Result(property = "role.roleName", column = "role_name")
    })
    List<Doctor> getDoctorByBatchId(@Param("ids") List<Long> ids);
}




